﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace UserForms
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {

            var name = textBox1.Text;
            var pwd = textBox2.Text;

            if(textBox1.Text.Length!=0 && textBox2.Text.Length!=0)
            {

                string sql = string.Format("select * from Student0002 where s_name='{0}' and s_pwd='{1}'", name, pwd);

                DataTable mytable=ADOopertion.Select(sql);


                var myrow = mytable.Rows.Count;


                if (myrow==1)
                {
                    MessageBox.Show("登入成功");

                    Form3 form3 = new Form3();

                    form3.Show();

                }
                else
                {
                    MessageBox.Show("登入失败");
                }
                
            }
            else
            {
                MessageBox.Show("密码或者账号不能为空！！");
                textBox1.Clear();
                textBox2.Clear();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 register = new Form2();

            register.Show();
        }
    }
}
